package tichu_project252.Controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import tichu_project252.Model.Model;
import tichu_project252.View.Player.OverlapLayout;
import tichu_project252.View.Player.PlayerCards;

/**
 * Handles the cards that are chosen.
 *
 * <p> <b> Invariants: </b> </p>
 *
 * @author Alexandra Barka, ΑΜ: 2867, login : barka.
 * @author Euaggelia Petauraki AM: 2875 login: petavraki.
 * @version %I%, %G%
 *
 */
public class chooseCards extends Controller implements ActionListener {

    
    /**
     * The chooseCards defines the behavior of the cards that are selected from
     * the user.
     *
     * <p><b>Constructor: </b>chooseCards(Model m)</p>
     *
     * <p><b>Precondition: </b> There is a model </p> <p><b>Postcondition: </b>
     * constructs a valid controller </p>
     *
     * @see <a
     * href="http://docs.oracle.com/javase/tutorial/java/IandI/super.html">super</a>
     *
     */
    public chooseCards(Model m) {
        super(m);
    }

    /**
     * Invoked when an action occurs.
     *
     * <p><b>Precondition: </b> The button is pushed </p> <p><b>Postcondition:
     * </b> The method handleChoose is performed. </p>
     *
     * @see ActionListener
     * @see <a
     * href="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/EventObject.html#getSource()">getSource()</a>
     *
     *
     */
    @Override
    public void actionPerformed(ActionEvent e) {
        Object temp = e.getSource();
        PlayerCards button = (PlayerCards) temp;
        m.handleChoose(button, button.getCard());
    }
}
